<%targetItem=this.target_item || {};%>
<form>
	<table class="form-table">
		<tr>
			<th>Category</th>
			<td><input type="text" verify="notNull" autocomplete_action="categories#autocomplete" name="category"
				value="<%=(targetItem.category ? targetItem.category.name : '').tagpropEscape()%>"
				hidden_field_initial_value="<%=(targetItem.category ? targetItem.category.id : '')%>"
				/></td>
			<td rowspan="6">
				<%if(this.target_item){%>
					<input type="hidden" name="request_items[]" value="<%=targetItem.id%>"/>
				<%}%>
				<div
					autodisplay_action="items#suggestForNewRequest" ejs="items/suggestions"
					autodisplay_events="change"
					data-extra_args_collector="collectFormData"
					data-extra_args_json="<%=tagpropEscapeJson({ignore_item:targetItem.id})%>"
					go_up="form" go_down="input"
					preserve_checkboxes="true"
					<%if(this.target_item){%>
						trigger_on_load="true"
					<%}%>
					></div>
			</td>
		</tr>
		<tr>
			<th>Title</th>
			<td><input class="input-box" type="text" size="35" verify="notNull" name="title"
				value="<%=(targetItem.name||this.search_string||'').tagpropEscape()%>"/></td>
		</tr>
		<tr>
			<th>Until</th>
			<td><input class="input-box" type="datepicker" size="10" verify="notNull dateAlreadyPassed"
				name="until_date" value="<%=(targetItem.until_date||'').tagpropEscape()%>"/></td>
		</tr>
		<tr>
			<th>Description</th>
			<td><textarea class="input-box" name="description" cols="37" rows="5"><%=(targetItem.description||'').htmlEscape()%></textarea></td>
		</tr>
		<tr>
			<th>Tags</th>
			<td><input class="input-box" type="text" name="tags" size="35"
				autocomplete_action="tags#autocomplete" multi_complete="default" multi_complete_padright=" "
				data-extra_args_collector="collectValueFromElement" extra_arg_name="preferred_category_id"
				go_up="form" go_down="[name=category_id]"
				value="<%=targetItem.tags ? targetItem.tags.join(', ').tagpropEscape() : ''%>"
				/></td>
		</tr>

		<tr>
			<th colspan="2" align="left">
				Post on my wall?
				<input type="checkbox" name="post_on_wall" checked="true"/>
			</th>
		</tr>

		<tr>
			<td colspan="2">
				<button style="width:100%"
					action="requests#add"
					close_parent="[container=dialog]"
					render_parent_ejs="items/succeed_message_request"
					trigger_along="reload-requests reload-suggestions rerun-last-search"
					>Request!</button>
			</td>
		</tr>
	</table>
</form>
